package com.net.model.viewmodel;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;

import com.net.model.model.BaseModel;

/**
 * 版权：周和权 版权所有
 *
 * @author zhouhequan
 * 版本：1.0
 * 创建日期：2021/11/13 or 11:43
 * 描述：---
 */
public abstract class BaseViewModel<T extends BaseModel> extends AndroidViewModel {
    public T baseModel;

    public BaseViewModel(@NonNull Application application) {
        super(application);
    }

    protected void bindBaseModel(final BaseModel baseModel) {
        this.baseModel = (T) baseModel;
    }


    protected T getRepository() {
        return baseModel;
    }


    @Override
    protected void onCleared() {
        super.onCleared();
        baseModel.unSubscribe();
    }
}
